package com.gs.gaosheng.controller;

import com.gs.common.annotation.Log;
import com.gs.common.core.controller.BaseController;
import com.gs.common.core.domain.AjaxResult;
import com.gs.common.core.page.TableDataInfo;
import com.gs.common.enums.BusinessType;
import com.gs.common.utils.poi.ExcelUtil;
import com.gs.gaosheng.domain.GsStatus;
import com.gs.gaosheng.service.GsStatusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 活动表Controller
 *
 * @author yy
 * @date 2023-08-03
 */
@RestController
@RequestMapping("/gaosheng/status")
public class GsStatusController extends BaseController
{
    @Autowired
    private GsStatusService gsStatusService;

    /**
     * 查询活动表列表
     */
    @GetMapping("/list")
    public TableDataInfo list(GsStatus gsStatus)
    {
        startPage();
        List<GsStatus> list = gsStatusService.selectGsStatusList(gsStatus);
        return getDataTable(list);
    }

    /**
     * 导出活动表列表
     */
    @Log(title = "活动表", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(GsStatus gsStatus)
    {
        List<GsStatus> list = gsStatusService.selectGsStatusList(gsStatus);
        ExcelUtil<GsStatus> util = new ExcelUtil<GsStatus>(GsStatus.class);
        return util.exportExcel(list, "status");
    }

    /**
     * 获取活动表详细信息
     */
    @GetMapping(value = "/{statusId}")
    public AjaxResult getInfo(@PathVariable("statusId") Long statusId)
    {
        return AjaxResult.success(gsStatusService.selectGsStatusById(statusId));
    }

    /**
     * 新增活动表
     */
    @Log(title = "活动表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GsStatus gsStatus)
    {
        return toAjax(gsStatusService.insertGsStatus(gsStatus));
    }

    /**
     * 修改活动表
     */
    @Log(title = "活动表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GsStatus gsStatus)
    {
        return toAjax(gsStatusService.updateGsStatus(gsStatus));
    }

    /**
     * 删除活动表
     */
    @Log(title = "活动表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{statusIds}")
    public AjaxResult remove(@PathVariable Long[] statusIds)
    {
        return toAjax(gsStatusService.deleteGsStatusByIds(statusIds));
    }
}
